﻿// -------------------------------------------------------------------------
//    @FileName         :    NFGMModule.h
//    @Author           :    Gao.Yi
//    @Date             :    2025-10-13
//    @Email			:    445267987@qq.com
//    @Module           :    NFGMModule
//    @Desc             :
//
// -------------------------------------------------------------------------

#pragma once

#include "NFComm/NFCore/NFPlatform.h"
#include "NFLogicCommon/NFMMODynamicModule.h"
#include "NFLogicDynamicModule.h"

class NFPlayer;
typedef std::function<int (NFPlayer* pPlayer, NFDataPackage& packet, const std::vector<std::string>& vecParams, std::string& info)> NFGMCmdHandler;

struct NFGMCmdData
{
    NFGMCmdData()
    {
        m_iPerm = 0;
        m_bIsTransOp = false;
    }
    std::string m_cmd;
    int m_iPerm;
    std::string m_helpInfo;
    bool m_bIsTransOp;
    NFGMCmdHandler m_handler;
};

class NFGMModule : public NFLogicDynamicModule
{
public:
    NFGMModule(NFIPluginManager* p);
    ~NFGMModule() override;
public:
    int Awake() override;
    int OnHandleClientMessage(NFDataPackage& packet, NFSession* pSession, const proto_ff::Proto_CSReq& req) override;
public:
    int OnHandleGMReq(NFDataPackage& packet, NFSession* pSession, const proto_ff::Proto_CSReq& req);
    int OnHandleOneGMReq(NFPlayer* pPlayer, NFDataPackage& packet, const std::string& cmd);
public:
    NFGMCmdData* GetGMCmdData(const std::string& cmd);
    int RegisterCMCmd(const std::string& cmd, int perm, const std::string& helpInfo, NFGMCmdHandler handler);
    int RegisterAllCmd();
private:
    std::unordered_map<std::string, NFGMCmdData> m_gmCmdMap;
};